﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace WordWonderGame.UI.Man4
{
    public partial class TimerMan4 : UserControl
    {
        public int Diem { get; set; }
        public int thoiGianHienTai;
        public event EventHandler XongMan4;
        int socauDung = 0;
        public TimerMan4()
        {
            InitializeComponent();
        }


        public void StartTimer()
        {
            thoiGianHienTai = 80;
            timer1.Start();
            hinhdong1.Visible = false;
            hinhdong2.Visible = false;
            hinhdong3.Visible = false;
            hinhdong4.Visible = false;
            hinhdong5.Visible = false;
            hinhdong6.Visible = false;
            hinhdong7.Visible = false;
            hinhdong8.Visible = false;
          


        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (thoiGianHienTai > 0)
            {
                thoiGianHienTai--;
                lblTime.Text = thoiGianHienTai.ToString();
                progressBar1.Value = 100 * thoiGianHienTai / 80;
            }
            else
            {
                timer1.Stop();
                timer2.Start();
            }
        }

        public void TraLoiDung()
        {
            SoundPlayer playerdung = new SoundPlayer(@"Sound\true.wav");
            playerdung.Play();
            Diem += 100;
            lblDiemSo.Text = Diem.ToString();   
            socauDung++;
            switch (socauDung)
            {
                case 1:
                    khauhieu.Image = imageList1.Images[0];
                    hinhdong1.Visible = true;
                    break;
                case 2:
                    khauhieu.Image = imageList1.Images[1];
                    hinhdong2.Visible = true;
                    break;
                case 3:
                    khauhieu.Image = imageList1.Images[2];
                    hinhdong3.Visible = true;
                    break;
                case 4:
                    khauhieu.Image = imageList1.Images[3];
                    hinhdong4.Visible = true;
                    break;
                case 5:
                    khauhieu.Image = imageList1.Images[4];
                    hinhdong5.Visible = true;
                    break;
                case 6:
                    khauhieu.Image = imageList1.Images[5];
                    hinhdong6.Visible = true;
                    break;
                case 7:
                    khauhieu.Image = imageList1.Images[6];
                    hinhdong7.Visible = true;
                    break;
                case 8:
                    khauhieu.Image = imageList1.Images[7];
                    hinhdong8.Visible = true;
                    break;

            }

        }
        

        public void CongDiemQuaMan()
        {
            timer1.Stop();
            timer3.Start();
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            if (thoiGianHienTai > 0)
            {
                thoiGianHienTai--;
                lblTime.Text = thoiGianHienTai.ToString();
                progressBar1.Value = 100 * thoiGianHienTai / 80;

                Diem += 3;
                lblDiemSo.Text = Diem.ToString();
            }
            else
            {
                timer3.Stop();
                timer2.Start();
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            timer2.Stop();
            if (XongMan4 != null)
            {
                XongMan4(Diem, null);
            }
        }
    }
}
